<template>
  <div class='hotContainer'>
    <div class='title'>
      <img src='https://imgs.qunarzz.com/piao/fusion/1711/16/bfbb9874e8f11402.png' />
      <h4>本周热门榜单</h4>
      <span>全部榜单 <i class ='fa fa-angle-right'></i></span>
    </div>
 <div class='person-wrap' ref='personWrap'>
  <ul class='person-list' ref='personTab'>
    <li class='person-item' v-for="item in top" :key = "item.id">
      <div class="top">
        <img :src="item.top" alt="">
      </div>
      <img :src="item.imgUrl" alt="">
      
      <p>{{item.title}}</p>
      <p><span>￥{{item.desc}}元</span>起</p>
    </li>
  </ul>
</div>
  </div>
</template>
<script>
  import BScroll from 'better-scroll'
export default {
  name: 'ReserveInfo',
  data() {
    return {};
  },
  created() {
    this.$nextTick(() => {
      this.personScroll();
    })
  },
  props:["top"],
  methods: {
    personScroll() {
     // 默认有六个li子元素，每个子元素的宽度为120px
      let width = 6 * 100;
      this.$refs.personTab.style.width = width + "px";
      // this.$nextTick 是一个异步函数，为了确保 DOM 已经渲染
      this.$nextTick(() => {
        if (!this.scroll) {
          this.scroll = new BScroll(this.$refs.personWrap, {
            startX: 0,
            click: true,
            scrollX: true,
            // 忽略竖直方向的滚动
            scrollY: false,
            eventPassthrough: 'vertical'
          });
        } else {
          this.scroll.refresh();
        }
      })
    }
  }
}
</script>
<style lang='less' scoped>
@font: 100px;
.hotContainer {
  margin-top: 10px;
  background: #fff;
  .title {
    display: flex;
    padding-bottom:20rem/@font;
    img {
      width:15rem / @font;
      height:15rem /@font;
      margin-top:7rem / @font;
    }
    h4 {
      font-size: 15rem / @font;
      font-weight: normal;
      margin-top: 5px;
    }
    span {
     margin-left:auto;
      font-size:12rem / @font;
      margin-right:15px;
      i{
        font-size:17rem/@font;
      }
    }
  }
  .person-wrap {
    overflow:hidden;
    .person-list{
      display:flex;
     .person-item {
       .top {
         position:relative;
         img{
           position:absolute;
           width:40rem/@font;
           height:20rem/@font;
         }
       }
       padding:5px;
        img {
        width:100rem/@font;
        height:100rem/@font;
        display:block;
      }
      p{
        text-align:center;
        font-size:12rem/@font;
        span{
          color:orange;
      
        }
      }
     }
    }
  }
}

</style>